package com.chixing.day09.day09_Homework;

public class StringHW {
    public static void main(String[] args) {
//        1. 将指定字符串全部转换成大写
        String str = "Early to bed and early to rise makes a man healthy, wealthy and wise. ";
        System.out.println(str.toUpperCase());

//        2. 将指定字符串全部转换成小写
        System.out.println(str.toLowerCase());

//        3. 获得指定字符串的第一个字符
        System.out.println(str.charAt(0));


//        4. 获得指定字符串的每一个字符
        for (int i = 0; i < str.length(); i++) {
            System.out.println(str.charAt(i));
        }

//        5. 获得指定字符串的字符长度
        System.out.println(str.length());

//        6.将两个字符串拼接成一个字符串
        String str1 = "Hellow ";
        String str2 = "This is Jason Marslyon speaking ";
        System.out.println(str1.concat(str2));

//        6. 将指定字符串中的a字母转换成Z
        System.out.println(str.replace("a", "Z"));

//        7. 获得指定字符串中的a字母出现的下标
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == 'a') {
                System.out.println(i);
            }
        }

//        9.获得字符串"clone-finalize-getClass-notify-notifyAll-wait" 中的每个单词
        String str3 = "clone-finalize-getClass-notify-notifyAll-wait";
        String[] arr = str3.split("-");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }


//        10.将数值76转换成字符串
        int num = 76;
        String str4 = String.valueOf(num);
        System.out.println(str4);

//        11.将数值57.8转换成字符串
        double d = 57.8;
        String str5 = String.valueOf(d);
        System.out.println(str5);
    }
}
